package com.ruoyi.projects.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.projects.domain.JwEduReformProjects;
import com.ruoyi.projects.service.IJwEduReformProjectsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 教育教学改革课题情况Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/projects/projects")
public class JwEduReformProjectsController extends BaseController
{
    @Autowired
    private IJwEduReformProjectsService jwEduReformProjectsService;

    /**
     * 查询教育教学改革课题情况列表
     */
    @PreAuthorize("@ss.hasPermi('projects:projects:list')")
    @GetMapping("/list")
    public TableDataInfo list(JwEduReformProjects jwEduReformProjects)
    {
        startPage();
        List<JwEduReformProjects> list = jwEduReformProjectsService.selectJwEduReformProjectsList(jwEduReformProjects);
        return getDataTable(list);
    }

    /**
     * 导出教育教学改革课题情况列表
     */
    @PreAuthorize("@ss.hasPermi('projects:projects:export')")
    @Log(title = "教育教学改革课题情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JwEduReformProjects jwEduReformProjects)
    {
        List<JwEduReformProjects> list = jwEduReformProjectsService.selectJwEduReformProjectsList(jwEduReformProjects);
        ExcelUtil<JwEduReformProjects> util = new ExcelUtil<JwEduReformProjects>(JwEduReformProjects.class);
        util.exportExcel(response, list, "教育教学改革课题情况数据");
    }

    /**
     * 获取教育教学改革课题情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('projects:projects:query')")
    @GetMapping(value = "/{erpId}")
    public AjaxResult getInfo(@PathVariable("erpId") Long erpId)
    {
        return success(jwEduReformProjectsService.selectJwEduReformProjectsByErpId(erpId));
    }

    /**
     * 新增教育教学改革课题情况
     */
    @PreAuthorize("@ss.hasPermi('projects:projects:add')")
    @Log(title = "教育教学改革课题情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JwEduReformProjects jwEduReformProjects)
    {
        SysUser user= SecurityUtils.getLoginUser().getUser();
        jwEduReformProjects.setDeptId(104L);
        jwEduReformProjects.setUserId(user.getUserId());
        return toAjax(jwEduReformProjectsService.insertJwEduReformProjects(jwEduReformProjects));
    }

    /**
     * 修改教育教学改革课题情况
     */
    @PreAuthorize("@ss.hasPermi('projects:projects:edit')")
    @Log(title = "教育教学改革课题情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JwEduReformProjects jwEduReformProjects)
    {
        return toAjax(jwEduReformProjectsService.updateJwEduReformProjects(jwEduReformProjects));
    }

    /**
     * 删除教育教学改革课题情况
     */
    @PreAuthorize("@ss.hasPermi('projects:projects:remove')")
    @Log(title = "教育教学改革课题情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{erpIds}")
    public AjaxResult remove(@PathVariable Long[] erpIds)
    {
        return toAjax(jwEduReformProjectsService.deleteJwEduReformProjectsByErpIds(erpIds));
    }
}
